-
Notifications
You must be signed in to change notification settings - Fork 19.6k
Add support for Rockblock 9704 satellite modem #31296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
-- compute CRC-16/XMODEM checksum of text | ||
---@param text string | ||
---@return integer -- checksum | ||
function crc_xmodem(text) end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be interesting to do some bench-marking vs a native lua implementation. I'm a little reluctant to start a president crc bindings just because there are so many people may want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A crc implementation in lua for example:
ardupilot/libraries/AP_Scripting/examples/TraxxasVelineon.lua
Lines 15 to 40 in da01dac
--- Apply a byte to the crc and return the result | |
---@param crc integer | |
---@param byte integer | |
---@return integer | |
local function applyCRCByte(crc, byte) | |
crc = crc ~ byte | |
for _ = 1, 8 do | |
if (crc & 0x80) ~= 0 then | |
crc = ((crc << 1) ~ 0xE7) & 0xFF | |
else | |
crc = (crc << 1) & 0xFF | |
end | |
end | |
return crc | |
end | |
--- Apply a table of bytes to the crc and return the result | |
---@param crc integer | |
---@param data integer[] | |
---@return integer | |
local function applyCRC(crc, data) | |
for i = 1, #data do | |
crc = applyCRCByte(crc, data[i]) | |
end | |
return crc | |
end |
@IamPete1 Here's one I put together:
Calculating the CRC16 of a 50 byte string has the following execution time on a CubeOrangePlus:
So the Lua bindings are ~50x faster |
Those timings are remarkable. @stephendade not a good idea to mix in the streamrate changes with the 9704 support. Please split that out to a separate PR for separate discussion (I think I'm OK with it, but I'm wondering if we should add an option bit to allow people to use initial stream rates if they are still keen to do so). |
Ouch. I guess the binding is worth it. My only hesitation is that I don't want to have a binding for every crc. How would you feel about a more generic binding where you can pass the polynomial? |
If that ends up as the solution please put the common polynomials (ex. MAVLink, CRSF) in docs.lua as a comment. |
eb36508
to
e31ce51
Compare
Done. See #31331.
My own thoughts are we only add bindings for commonly used CRC's. Looking through the AP_Scripting, the Xmodem CRC is used in >5 scripts, so that seems an obvious candidate. |
Somewhat related: #27355 . There is a reasonably well defined taxonomy of CRCs more than the polynomial that we do not exploit. You could also make the Lua faster by using a table, at least likely to the point doing it in Lua is not a performance concern. Several other Lua scripts already do this. |
This also makes me more concerned about doing mavlink CRC checks in the script in #31268 . I will do some investigation myself. |
This PR adds support for the Rockblock 9704 satellite modem (https://www.groundcontrol.com/product/rockblock-9704/), using the MAVLink High Latency protocol. It sends a
HIGH_LATENCY2
packet once per 30 seconds.The software required at the GCS to process messages is at stephendade/rockblock2mav#5
I also:
Tested in hardware with a CubeOrange+.
(Thanks to GroundControl for supplying the hardware and airtime)